package com.jk1123.dotdog.server;

import com.jk1123.dotdog.server.Bootstrap;

import java.net.ServerSocket;
import java.util.concurrent.ExecutorService;

public class DotDog {
    public static final  int DEFAULT_PORT=8889;
    private int port;
    private Bootstrap bootstrap=new Bootstrap();
    private ServletContainer servletContainer=new ServletContainer();

    public ServletContainer getServletContainer() {
        return servletContainer;
    }

    public DotDog() {
        this.port = DEFAULT_PORT;
    }

    public DotDog(int port) {
        this.port = port;
    }

    public void start(){
        Banner.print();
        ServerSocket serverSocket = bootstrap.bind(port);
        System.out.println("the server is starting ~~~ the port is:"+port);
        ExecutorService workerPool = bootstrap.initThreadPools();
        //System.out.println("初始化线程池完毕~~~");
        bootstrap.start(workerPool,serverSocket,servletContainer);
        System.out.println("the server is started~~~");

    }



}
